//
//  BaseNavigationView.m
//  ZITHER
//
//  Created by imac on 2018/5/28.
//  Copyright © 2018年 MinesTime. All rights reserved.
//

#import "BaseNavigationView.h"

@implementation BaseNavigationView

+ (BaseNavigationView *)instanceWithFrame:(CGRect)frame {
    BaseNavigationView *view = (BaseNavigationView *)[[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil] firstObject];
    view.frame = frame;
    return view;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.frame = CGRectMake(0, 0, kScreenW, NaviHeight);
    [self layoutIfNeeded];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

#pragma mark - Setter
- (void)setIsShowShadow:(BOOL)isShowShadow {
    _isShowShadow = isShowShadow;
    if (_isShowShadow) {
        [self setShadowType1WithColor:[UIColor defaultShadowColor] offset:CGSizeMake(0, 3) opacity:1 radius:2];
    } else {
        [self setShadowType1WithColor:[UIColor clearColor] offset:CGSizeMake(0, 5) opacity:1 radius:3];
    }
}

- (IBAction)buttonClick:(UIButton *)sender {
    NavigationViewClickType type = NavigationViewClickTypeNone;
    switch (sender.tag) {
        case 1: { // left1
            type = NavigationViewClickTypeLeft1;
        } break;
        case 11: { // right1
            type = NavigationViewClickTypeRight1;
        } break;
        case 12: { // right2
            type = NavigationViewClickTypeRight2;
        } break;
        default:
            break;
    }
    if (self.navigationViewClickBlock) {
        self.navigationViewClickBlock(type, sender);
    }
}


-(void)NavigationBarStyle:(NavigationBarStyle)NavigationBarStyle{
    self.leftButton1.hidden = YES;
    switch (NavigationBarStyle) {
        case NavigationBarStyleSKU:{
            NSLog(@"SKU 导航栏");
            self.NavStyleSKUV = [[NavStyleSKU alloc]initWithFrame:CGRectMake(0, 0, 1, 1)];
            [self addSubview:self.NavStyleSKUV];
            
            CGFloat height = kStatusBarHeight +14+25+14 +25+5+10+28;
            
            [self.NavStyleSKUV mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.left.right.mas_equalTo(self).offset(0);
                make.height.mas_equalTo(height);
            }];
        }
            break;
            
        case NavViewStyle:{
            NSLog(@"V4通用导航栏");
            self.navViewStyle = [[navViewStyle alloc]initWithFrame:CGRectMake(0, 0, kScreenW, NaviHeight)];
            [self addSubview:self.navViewStyle];
        }
            break;
        case NavViewStyleMyIntere:{
            NSLog(@"V4通用导航栏");
            self.NavViewStyleMyInterest = [[NavViewStyleMyInterest alloc]initWithFrame:CGRectMake(0, 0, kScreenW, NaviHeight)];
            [self addSubview:self.NavViewStyleMyInterest];
        }
            break;
        case NavigationViewTitleLeft1:{
            self.NavigationViewTitleLeft = [[NavigationViewTitleLeft alloc]initWithFrame:CGRectMake(0, 0, kScreenW, NaviHeight)];
            [self addSubview:self.NavigationViewTitleLeft];
        }
            break;

        default:
            break;
    }
}

-(void)setHiddenNav:(BOOL)type VC:(UIViewController*)vc{
    if (type) {
        self.hidden = YES;
        [vc.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
        [vc.navigationItem setHidesBackButton:YES];
        vc.navigationController.navigationBar.shadowImage = [UIImage new];
        [self setBackgroundColor:[UIColor clearColor]];
        self.bottomLineView.backgroundColor = [UIColor clearColor];
        self.leftButton1.hidden = YES;
    }else{
        self.isShowShadow = YES;
        [vc.navigationItem setHidesBackButton:YES];
    }
    
}


@end
